﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using Leadtools;
using Leadtools.Demos;
using Leadtools.Dicom;

namespace DICOMDataMasker
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            //设置License
            if (!Support.SetLicense())
                return;
            //leadtools验证liccense
            if (RasterSupport.IsLocked(RasterSupportType.DicomCommunication))
            {
                Console.WriteLine("License error!");
                MessageBox.Show(
                    String.Format("{0} Support is locked!", RasterSupportType.DicomCommunication.ToString()),
                    "Warning");
                return;
            }

            //对Uac进行判断，如果需要提升权限进行运行，已通过manifest设置requireAdministrator绕过
            if (DemosGlobal.MustRestartElevated())
            {
                Console.WriteLine("Try Restart Elevated !");
                DemosGlobal.TryRestartElevated(args);
                return;
            }
            //启动leadtools引擎，DicomEngine.Startup();
            DicomEngine.Startup();
            //DicomNet.Startup();
            DicomNet.Startup();
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.ApplicationExit += Application_ApplicationExit;
            Application.Run(new MainForm());
        }
        private static void Application_ApplicationExit(object sender, EventArgs e)
        {
            DicomEngine.Shutdown();
            DicomNet.Shutdown();
        }
    }
}
